package com.headcaselabs.orchestra;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;

import com.thoughtworks.xstream.XStream;

/**
 * Simple Configuratoin Parameters
 * @author Florian Leibert
 *
 */
public class Configuration {
	
	private long checkInterval;
	private long maxJobTime;
	
	private ArrayList<String> queues;
	private ArrayList<Double> queueWeights;
	private ArrayList<Long>queueExpectedProcessingTimes;
	private ArrayList<Long> queueCpuTimes;
	private ArrayList<Integer> timeouts;
	private String reportQueue;
	private int reportQueueTimeout;
	private int defaultTimeout;
	
	private String awsAccessKey;
	private String jobDirectory;
	private String awsSecretKey;
	private String keyName;
	
	private String reportDirectory;
	private String cancelledJobDirectory;
	private int threadCount;
	
	private Long workingTime;
	private Long reportInterval;
	private Long sleepOnEmptyQueues;
	private String loadScript;
	private double maxLoad;
	
	
	public Configuration() {
		queues = new ArrayList<String>();
		queueWeights = new ArrayList<Double>();
		queueExpectedProcessingTimes = new ArrayList<Long>();
		queueCpuTimes = new ArrayList<Long>();
		timeouts = new ArrayList<Integer>();
	}
	
	public static Configuration getConfiguration(String configFile) {
		XStream xstream = new XStream();
  	xstream.alias("configuration", Configuration.class);
  	
  	File f = new File(configFile);
  	if (!f.exists()) {
  		throw new RuntimeException("Sorry, Configuration File not found.");
  	}
  	Configuration conf = null;
  	try {
  		conf = (Configuration)xstream.fromXML(new FileInputStream(configFile));
  	} catch (IOException ioe) {
  		ioe.printStackTrace();
  	}
  	return conf;
	}

	/**
	 * @return the awsAccessKey
	 */
	public String getAwsAccessKey() {
		return awsAccessKey;
	}

	/**
	 * @param awsAccessKey the awsAccessKey to set
	 */
	public void setAwsAccessKey(String awsAccessKey) {
		this.awsAccessKey = awsAccessKey;
	}

	/**
	 * @return the awsSecretKey
	 */
	public String getAwsSecretKey() {
		return awsSecretKey;
	}

	/**
	 * @param awsSecretKey the awsSecretKey to set
	 */
	public void setAwsSecretKey(String awsSecretKey) {
		this.awsSecretKey = awsSecretKey;
	}

	/**
	 * @return the checkInterval
	 */
	public long getCheckInterval() {
		return checkInterval;
	}

	/**
	 * @param checkInterval the checkInterval to set
	 */
	public void setCheckInterval(long checkInterval) {
		this.checkInterval = checkInterval;
	}

	/**
	 * @return the keyName
	 */
	public String getKeyName() {
		return keyName;
	}

	/**
	 * @param keyName the keyName to set
	 */
	public void setKeyName(String keyName) {
		this.keyName = keyName;
	}


	/**
	 * @return the maxJobTime
	 */
	public long getMaxJobTime() {
		return maxJobTime;
	}

	/**
	 * @param maxJobTime the maxJobTime to set
	 */
	public void setMaxJobTime(long maxJobTime) {
		this.maxJobTime = maxJobTime;
	}

	/**
	 * @return the queueCpuTimes
	 */
	public ArrayList<Long> getQueueCpuTimes() {
		return queueCpuTimes;
	}

	/**
	 * @param queueCpuTimes the queueCpuTimes to set
	 */
	public void setQueueCpuTimes(ArrayList<Long> queueCpuTimes) {
		this.queueCpuTimes = queueCpuTimes;
	}

	/**
	 * @return the queueExpectedProcessingTimes
	 */
	public ArrayList<Long> getQueueExpectedProcessingTimes() {
		return queueExpectedProcessingTimes;
	}

	/**
	 * @param queueExpectedProcessingTimes the queueExpectedProcessingTimes to set
	 */
	public void setQueueExpectedProcessingTimes(
			ArrayList<Long> queueExpectedProcessingTimes) {
		this.queueExpectedProcessingTimes = queueExpectedProcessingTimes;
	}

	/**
	 * @return the queues
	 */
	public ArrayList<String> getQueues() {
		return queues;
	}

	/**
	 * @param queues the queues to set
	 */
	public void setQueues(ArrayList<String> queues) {
		this.queues = queues;
	}

	/**
	 * @return the queueWeights
	 */
	public ArrayList<Double> getQueueWeights() {
		return queueWeights;
	}

	/**
	 * @param queueWeights the queueWeights to set
	 */
	public void setQueueWeights(ArrayList<Double> queueWeights) {
		this.queueWeights = queueWeights;
	}

	/**
	 * @return the timeouts
	 */
	public ArrayList<Integer> getTimeouts() {
		return timeouts;
	}

	/**
	 * @param timeouts the timeouts to set
	 */
	public void setTimeouts(ArrayList<Integer> timeouts) {
		this.timeouts = timeouts;
	}

	/**
	 * @return the reportQueue
	 */
	public String getReportQueue() {
		return reportQueue;
	}

	/**
	 * @param reportQueue the reportQueue to set
	 */
	public void setReportQueue(String reportQueue) {
		this.reportQueue = reportQueue;
	}

	/**
	 * @return the reportQueueTimeout
	 */
	public int getReportQueueTimeout() {
		return reportQueueTimeout;
	}

	/**
	 * @param reportQueueTimeout the reportQueueTimeout to set
	 */
	public void setReportQueueTimeout(int reportQueueTimeout) {
		this.reportQueueTimeout = reportQueueTimeout;
	}

	/**
	 * @return the defaultTimeout
	 */
	public int getDefaultTimeout() {
		return defaultTimeout;
	}

	/**
	 * @param defaultTimeout the defaultTimeout to set
	 */
	public void setDefaultTimeout(int defaultTimeout) {
		this.defaultTimeout = defaultTimeout;
	}

	/**
	 * @return the jobDirectory
	 */
	public String getJobDirectory() {
		return jobDirectory;
	}

	/**
	 * @param jobDirectory the jobDirectory to set
	 */
	public void setJobDirectory(String jobDirectory) {
		this.jobDirectory = jobDirectory;
	}

	/**
	 * @return the workingTime
	 */
	public Long getWorkingTime() {
		return workingTime;
	}

	/**
	 * @param workingTime the workingTime to set
	 */
	public void setWorkingTime(Long workingTime) {
		this.workingTime = workingTime;
	}

	/**
	 * @return the reportInterval
	 */
	public Long getReportInterval() {
		return reportInterval;
	}

	/**
	 * @param reportInterval the reportInterval to set
	 */
	public void setReportInterval(Long reportInterval) {
		this.reportInterval = reportInterval;
	}

	/**
	 * @return the sleepOnEmptyQueues
	 */
	public Long getSleepOnEmptyQueues() {
		return sleepOnEmptyQueues;
	}

	/**
	 * @param sleepOnEmptyQueues the sleepOnEmptyQueues to set
	 */
	public void setSleepOnEmptyQueues(Long sleepOnEmptyQueues) {
		this.sleepOnEmptyQueues = sleepOnEmptyQueues;
	}

	/**
	 * @return the reportDirectory
	 */
	public String getReportDirectory() {
		return reportDirectory;
	}

	/**
	 * @param reportDirectory the reportDirectory to set
	 */
	public void setReportDirectory(String reportDirectory) {
		this.reportDirectory = reportDirectory;
	}

	/**
	 * @return the threadCount
	 */
	public int getThreadCount() {
		return threadCount;
	}

	/**
	 * @param threadCount the threadCount to set
	 */
	public void setThreadCount(int threadCount) {
		this.threadCount = threadCount;
	}

	/**
	 * @return the maxLoad
	 */
	public double getMaxLoad() {
		return maxLoad;
	}

	/**
	 * @param maxLoad the maxLoad to set
	 */
	public void setMaxLoad(double maxLoad) {
		this.maxLoad = maxLoad;
	}

	/**
	 * @return the loadScript
	 */
	public String getLoadScript() {
		return loadScript;
	}

	/**
	 * @param loadScript the loadScript to set
	 */
	public void setLoadScript(String loadScript) {
		this.loadScript = loadScript;
	}

	/**
	 * @return the cancelledJobDirectory
	 */
	public String getCancelledJobDirectory() {
		return cancelledJobDirectory;
	}

	/**
	 * @param cancelledJobDirectory the cancelledJobDirectory to set
	 */
	public void setCancelledJobDirectory(String cancelledJobDirectory) {
		this.cancelledJobDirectory = cancelledJobDirectory;
	}
	

	
	

	
}


